/**
 * @param {string} s
 * @return {string}
 */
let reverseWords = function (s) {
    let sArr = s.split(" "),
        left = 0,
        right = sArr.length - 1,
        res = ''


    while (left < right) {
        while (sArr[left] === "") {
            left++
        }
        while (sArr[right] === "") {
            right--
        }
        if (left < right) {
            console.log(sArr[left], sArr[right])
            let temp = sArr[left];
            sArr[left] = sArr[right];
            sArr[right] = temp;
            left++;
            right--;
        }
    }

    for (let i = 0; i < sArr.length; i++) {
        if (sArr[i] !== "") {
            res = res + sArr[i] + " "
        }
    }

    return res.slice(0, res.length - 1)
};